home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 41 / Amiga Format CD41 (1999-06)(Future Publishing)(GB)[!][issue 1999-07].iso / -seriously_amiga- / programming / other / scm / slib / umbscheme.init < prev    next >
Text File  |  1999-04-19  |  8KB  |  264 lines

  1. ;;; "umbscheme.init" Initialization for SLIB for umb-scheme -*-scheme-*-
  2. ;;; Author: Aubrey Jaffer
  3. ;;;
  4. ;;; This code is in the public domain.
  5.  
  6. ; MODIFIED BY Bill Campbell for UMB Scheme.
  7.  
  8. ; Further modified by Radey Shouman, for inclusion in SLIB.
  9.  
  10. ;;; (software-type) should be set to the generic operating system type.
  11. ;;; UNIX, VMS, MACOS, AMIGA and MS-DOS are supported.
  12.  
  13. (define (software-type) 'UNIX)
  14.  
  15. ;;; (scheme-implementation-type) should return the name of the scheme
  16. ;;; implementation loading this file.
  17.  
  18. (define (scheme-implementation-type) 'umb-scheme)
  19.  
  20. ;;; (scheme-implementation-home-page) should return a (string) URL
  21. ;;; (Uniform Resource Locator) for this scheme implementation's home
  22. ;;; page; or false if there isn't one.
  23.  
  24. (define (scheme-implementation-home-page)
  25.   "ftp://ftp.cs.umb.edu:/pub/scheme/")
  26.  
  27. ;;; (scheme-implementation-version) should return a string describing
  28. ;;; the version the scheme implementation loading this file.
  29.  
  30. (define (scheme-implementation-version) "3.2")
  31.  
  32. ;;; (implementation-vicinity) should be defined to be the pathname of
  33. ;;; the directory where any auxillary files to your Scheme
  34. ;;; implementation reside.
  35.  
  36. (define (implementation-vicinity)
  37.   (case (software-type)
  38.     ((UNIX)     "/usr/lib/umb-scheme/")
  39.     ((VMS)    "scheme$src:")
  40.     ((MS-DOS)    "C:\\scheme\\")))
  41.  
  42. ;;; (library-vicinity) should be defined to be the pathname of the
  43. ;;; directory where files of Scheme library functions reside.
  44.  
  45. (define library-vicinity
  46.   (let ((library-path
  47.      (or
  48.       ;; Use this getenv if your implementation supports it.
  49.       ;;(getenv "SCHEME_LIBRARY_PATH")
  50.       ;; Use this path if your scheme does not support GETENV
  51.       ;; or if SCHEME_LIBRARY_PATH is not set.
  52.       (case (software-type)
  53.         ((UNIX) "/usr/lib/umb-scheme/slib/")
  54.         ((VMS) "lib$scheme:")
  55.         ((MS-DOS) "C:\\SLIB\\")
  56.         (else "")))))
  57.     (lambda () library-path)))
  58.  
  59. ;;; (home-vicinity) should return the vicinity of the user's HOME
  60. ;;; directory, the directory which typically contains files which
  61. ;;; customize a computer environment for a user.
  62.  
  63. (define (home-vicinity) "")
  64.  
  65. ;;; *FEATURES* should be set to a list of symbols describing features
  66. ;;; of this implementation.  Suggestions for features are:
  67.  
  68. (define *features*
  69.       '(
  70.     source                ;can load scheme source files
  71.                     ;(slib:load-source "filename")
  72. ;    compiled            ;can load compiled files
  73.                     ;(slib:load-compiled "filename")
  74. ;    rev4-report            ;conforms to
  75. ;    rev3-report            ;conforms to
  76.     ieee-p1178            ;conforms to
  77. ;    sicp                ;runs code from Structure and
  78.                     ;Interpretation of Computer
  79.                     ;Programs by Abelson and Sussman.
  80.     rev4-optional-procedures    ;LIST-TAIL, STRING->LIST,
  81.                     ;LIST->STRING, STRING-COPY,
  82.                     ;STRING-FILL!, LIST->VECTOR,
  83.                     ;VECTOR->LIST, and VECTOR-FILL!
  84. ;    rev2-procedures            ;SUBSTRING-MOVE-LEFT!,
  85.                     ;SUBSTRING-MOVE-RIGHT!,
  86.                     ;SUBSTRING-FILL!,
  87.                     ;STRING-NULL?, APPEND!, 1+,
  88.                     ;-1+, <?, <=?, =?, >?, >=?
  89.     multiarg/and-            ;/ and - can take more than 2 args.
  90.     multiarg-apply            ;APPLY can take more than 2 args.
  91.     rationalize
  92.     delay                ;has DELAY and FORCE
  93.     with-file            ;has WITH-INPUT-FROM-FILE and
  94.                     ;WITH-OUTPUT-FROM-FILE
  95. ;    string-port            ;has CALL-WITH-INPUT-STRING and
  96.                     ;CALL-WITH-OUTPUT-STRING
  97.     transcript            ;TRANSCRIPT-ON and TRANSCRIPT-OFF
  98.     char-ready?
  99. ;    macro                ;has R4RS high level macros
  100.     defmacro            ;has Common Lisp DEFMACRO
  101. ;    eval                ;SLIB:EVAL is single argument eval
  102. ;    record                ;has user defined data structures
  103. ;    values                ;proposed multiple values
  104. ;    dynamic-wind            ;proposed dynamic-wind
  105. ;    ieee-floating-point        ;conforms to
  106.     full-continuation        ;can return multiple times
  107. ;    object-hash            ;has OBJECT-HASH
  108.  
  109. ;    sort
  110. ;    queue                ;queues
  111. ;    pretty-print
  112. ;    object->string
  113. ;    format
  114. ;    trace                ;has macros: TRACE and UNTRACE
  115. ;    compiler            ;has (COMPILER)
  116. ;    ed                ;(ED) is editor
  117.     system                ;posix (system <string>)
  118. ;    getenv                ;posix (getenv <string>)
  119. ;    program-arguments        ;returns list of strings (argv)
  120. ;    Xwindows            ;X support
  121. ;    curses                ;screen management package
  122. ;    termcap                ;terminal description package
  123. ;    terminfo            ;sysV terminal description
  124. ;    current-time            ;returns time in seconds since 1/1/1970
  125.     ))
  126.  
  127. ;;; (OUTPUT-PORT-WIDTH <port>)
  128. (define (output-port-width . arg) 79)
  129.  
  130. ;;; (OUTPUT-PORT-HEIGHT <port>)
  131. (define (output-port-height . arg) 24)
  132.  
  133. ;;; (CURRENT-ERROR-PORT)
  134. (define current-error-port
  135.   (let ((port (current-output-port)))
  136.     (lambda () port)))
  137.  
  138. ;;; (TMPNAM) makes a temporary file name.
  139. (define tmpnam (let ((cntr 100))
  140.          (lambda () (set! cntr (+ 1 cntr))
  141.              (string-append "slib_" (number->string cntr)))))
  142.  
  143. ;;; (FILE-EXISTS? <string>)
  144. ;;(define (file-exists? f) #f)
  145. (define file-exists?
  146.   (case (software-type)
  147.     ((UNIX)
  148.      (lambda (f)
  149.        (zero? (system (string-append "test -r " f)))))
  150.     (else
  151.      (lambda (f) #f))))
  152.  
  153. ;;; (DELETE-FILE <string>)
  154. ;;(define (delete-file f) #f)
  155. (define delete-file
  156.   (case (software-type)
  157.     ((UNIX)
  158.      (lambda (f)
  159.        (zero? (system (string-append "rm " f)))))
  160.     (else
  161.      (lambda (f) #f))))
  162.        
  163.  
  164. ;;; FORCE-OUTPUT flushes any pending output on optional arg output port
  165. ;;; use this definition if your system doesn't have such a procedure.
  166. (define (force-output . arg) #t)
  167.  
  168. ;;; CALL-WITH-INPUT-STRING and CALL-WITH-OUTPUT-STRING are the string
  169. ;;; port versions of CALL-WITH-*PUT-FILE.
  170.  
  171. ;;; CHAR-CODE-LIMIT is one greater than the largest integer which can
  172. ;;; be returned by CHAR->INTEGER.
  173. (define char-code-limit 256)
  174.  
  175. ;;; MOST-POSITIVE-FIXNUM is used in modular.scm
  176. (define most-positive-fixnum #x08000)
  177.  
  178. ;;; Return argument
  179. (define (identity x) x)
  180.  
  181. ;;; If your implementation provides eval SLIB:EVAL is single argument
  182. ;;; eval using the top-level (user) environment.
  183. (define slib:eval eval)
  184.  
  185. (define gentemp
  186.   (let ((*gensym-counter* -1))
  187.     (lambda ()
  188.       (set! *gensym-counter* (+ *gensym-counter* 1))
  189.       (string->symbol
  190.        (string-append "slib:G" (number->string *gensym-counter*))))))
  191.  
  192. (define defmacro:eval slib:eval)
  193. (define defmacro:load load)
  194.  
  195. (define (defmacro:load <pathname>)
  196.   (slib:eval-load <pathname> defmacro:eval))
  197.  
  198. (define (slib:eval-load <pathname> evl)
  199.   (if (not (file-exists? <pathname>))
  200.       (set! <pathname> (string-append <pathname> (scheme-file-suffix))))
  201.   (call-with-input-file <pathname>
  202.     (lambda (port)
  203.       (let ((old-load-pathname *load-pathname*))
  204.     (set! *load-pathname* <pathname>)
  205.     (do ((o (read port) (read port)))
  206.         ((eof-object? o))
  207.       (evl o))
  208.     (set! *load-pathname* old-load-pathname)))))
  209.  
  210. (define slib:warn
  211.   (lambda args
  212.     (let ((port (current-error-port)))
  213.       (display "Warn: " port)
  214.       (for-each (lambda (x) (display x port)) args))))
  215.  
  216. ;;; define an error procedure for the library
  217. (define slib:error error)
  218.  
  219. ;;; define these as appropriate for your system.
  220. (define slib:tab (integer->char 9))
  221. (define slib:form-feed (integer->char 12))
  222.  
  223. ;;; Support for older versions of Scheme.  Not enough code for its own file.
  224. (define (last-pair l) (if (pair? (cdr l)) (last-pair (cdr l)) l))
  225. (define t #t)
  226. (define nil #f)
  227.  
  228. ;;; Define these if your implementation's syntax can support it and if
  229. ;;; they are not already defined.
  230.  
  231. ;(define (1+ n) (+ n 1))
  232. ;(define (-1+ n) (+ n -1))
  233. ;(define 1- -1+)
  234.  
  235. (define in-vicinity string-append)
  236.  
  237. ;;; Define SLIB:EXIT to be the implementation procedure to exit or
  238. ;;; return if exitting not supported.
  239. (define slib:exit (lambda args #f))
  240.  
  241. ;;; Here for backward compatability
  242. (define scheme-file-suffix
  243.   (let ((suffix (case (software-type)
  244.           ((NOSVE) "_scm")
  245.           (else ".scm"))))
  246.     (lambda () suffix)))
  247.  
  248. ;;; (SLIB:LOAD-SOURCE "foo") should load "foo.scm" or with whatever
  249. ;;; suffix all the module files in SLIB have.  See feature 'SOURCE.
  250.  
  251. (define (slib:load-source f) (load (string-append f ".scm")))
  252.  
  253. ;;; (SLIB:LOAD-COMPILED "foo") should load the file that was produced
  254. ;;; by compiling "foo.scm" if this implementation can compile files.
  255. ;;; See feature 'COMPILED.
  256.  
  257. (define slib:load-compiled load)
  258.  
  259. ;;; At this point SLIB:LOAD must be able to load SLIB files.
  260.  
  261. (define slib:load slib:load-source)
  262.  
  263. (slib:load (in-vicinity (library-vicinity) "require"))
  264.